package org.pinda.network.auth;

import java.io.DataOutputStream;
import java.io.IOException;

import org.pinda.network.util.Stream;

public class PacketHandshakeResponse extends IAuthPacket {
	
	public static final short ID = 1;
	
	private boolean accepted;

	public PacketHandshakeResponse() {
		
	}
	
	public PacketHandshakeResponse(boolean accepted) {
		this.accepted = accepted;
	}

	@Override
	public void write(DataOutputStream outStream) throws IOException {
		outStream.writeBoolean(accepted);
	}

	@Override
	public void read(Stream inStream) throws IOException {
		accepted = inStream.readBoolean();
	}

	@Override
	public short getId() {
		return ID;
	}

	@Override
	public int getLength() {
		return 1;
	}

	@Override
	public boolean passedAuth() {
		return accepted;
	}

}
